<?php

/***  DOCUMENTATION LAYER

Klenwell Navbar Functions

Last Update: May 2007
Author: Tom at klenwell@gmail.com

FUNCTIONS
	kw_auto_navbar_list()

NOTES
	test script can be found here: 
		http://code.google.com/p/klenwell/PHP/_unit_tests/test.navbar.php
		
	sample css at bottom
	
______________________________________________________________________________*/


// kw_build_navbar
/*____________________________________________________________________________*/
function kw_auto_navbar_list($NAVBAR_ARRAY) 
{
// *** DATA

	// internal
	$active_url = $_SERVER['PHP_SELF'];
	$_list = '';

	// return
	$html = "";

// *** MANIPULATE

	// normalize country names
	foreach ( $NAVBAR_ARRAY as $label => $url )
	{
		// tidy labels
		$label = str_replace('_', ' ', $label);
		
		// check for active url
		$is_active = ( strpos($url, $active_url) !== FALSE ) ? 1 : 0;
		
		// active url?
		if ( $is_active )
		{
			$_list .= "<li><a class=\"active\" href=\"{$url}\">{$label}</a></li>\n";
		}
		else
		{
			$_list .= "<li><a href=\"{url}\">{$label}</a></li>\n";
		}
	}
	
	// wrap list
	$html = "<ul class=\"kw_navbar\">\n$_list\n</ul>";
	

// *** RETURN

	return $html;
} 
/*____________________________________________________________________________*/


// Sample CSS
/*______________________________________________________________________________

.kw_navbar 
{ 
 width:50%;
 margin:0 auto 8px;
 padding:4px 0px 2px;
 text-align:center;
 font:1em sans-serif;
 background:#eef;
 border:1px solid #ccf; 
}
.kw_navbar ul { margin:0 auto; padding:0; text-align:center; }
.kw_navbar li { display:inline; list-style:none; margin:0; padding:0; }
.kw_navbar a 
{ 
 padding:4px 12px; 
 margin:0 3px; 
 text-decoration:none; 
}
.kw_navbar a:hover { background:#ccd; }
.kw_navbar .active { font-weight:bold; }

______________________________________________________________________________*/

?>
